require 'Qt4'
load 'ui_mainform.rb'
load 'datehoureditor.rb'
load 'targeteditor.rb'
load 'taskviewer.rb'

class MainForm < Qt::MainWindow
	attr_accessor :ui
    attr_accessor :db
    
	slots   'edit_hours()','edit_targets()','see_tasks()'
    
	
	def init(db)
	    @db=db 
	
		@ui=Ui_Sheduler.new
        @ui.setupUi(self)
		self.show()
		
		Qt::Object.connect(@ui.btnEditHours,SIGNAL("clicked()"),self,SLOT("edit_hours()"))
		Qt::Object.connect(@ui.btnEditTargets,SIGNAL("clicked()"),self,SLOT("edit_targets()"))
		Qt::Object.connect(@ui.btnToday,SIGNAL("clicked()"),self,SLOT("see_tasks()"))
	end
	
	def edit_hours()
	    # This is user can edit spent hours on tasks job
		ed=DateHourEditor.new(self)
		ed.init(db)
	end
	
	def edit_targets()
	    #This is whete user can edit current targets, which he can use
		ed= TargetEditor.new(self)
		ed.init(db,0)
	end
	
	def see_tasks()
		 #This is whete user can view current tasks, which he can use
		ed= TaskViewer.new(self)
		ed.init(db)
	end
end